package com.changhai.diabetes.action;

import com.changhai.diabetes.model.LabLipids;
import com.changhai.diabetes.model.LabPhysical;
import com.changhai.diabetes.model.LabSugar;
import com.changhai.diabetes.model.LabUrine;
import com.changhai.diabetes.model.OpertResultMsg;
import com.changhai.diabetes.service.JianyanService;

/**
 * 检验随访
 * 
 * @author Andy
 * 
 */
public class JianyanAction extends BaseAction {

	private static final long serialVersionUID = 4392936553263004630L;
	private OpertResultMsg opertMsg;
	private Long patientid;
	private LabPhysical labphy;
	private LabSugar labsugar;
	private LabUrine laburine;
	private LabLipids lablipids;
	private JianyanService jianyanService;
	private Integer flag = 0;

	public String execute() throws Exception {
		return super.execute();
	}

	public String query() {
		return "input";
	}

	public String editJianyan() {
		if (patientid != null && patientid > 0) {
			try {
				labphy = jianyanService.searchPhyByPatientId(patientid);
				//labsugar = jianyanService.searchSugarByPatientId(patientid);
				//laburine = jianyanService.searchUrineByPatientId(patientid);
				//lablipids = jianyanService.searchLipidsByPatientId(patientid);
				tbList = this.getTableForEnter(patientid, flag);
			} catch (Exception e) {
				e.printStackTrace();
				opertMsg = new OpertResultMsg(Long.valueOf(1), "暂无信息!");
			}
			return "input";
		} else {
			return "query";
		}
	}

	public String saveEditJianyan() {
		if (patientid == null || patientid <= 0 || labphy == null || labsugar == null || laburine == null
				|| lablipids == null) {
			opertMsg = new OpertResultMsg(Long.valueOf(1), "参数错误!");
		} else {
			try {
				jianyanService.saveEditLabPhy(labphy);
				jianyanService.saveEditLabSugar(labsugar);
				jianyanService.saveEditLabLipids(lablipids);
				jianyanService.saveEditLabUrine(laburine);
				opertMsg = new OpertResultMsg(Long.valueOf(0), "保存成功!");
				commonService.writeLogToFile("update", "检验随访", patientid);
			} catch (Exception e) {
				opertMsg = new OpertResultMsg(Long.valueOf(1), "保存失败!");
			}
		}
		return this.editJianyan();
	}

	public OpertResultMsg getOpertMsg() {
		return opertMsg;
	}

	public void setOpertMsg(OpertResultMsg opertMsg) {
		this.opertMsg = opertMsg;
	}

	public Long getPatientid() {
		return patientid;
	}

	public void setPatientid(Long patientid) {
		this.patientid = patientid;
	}

	public LabPhysical getLabphy() {
		return labphy;
	}

	public void setLabphy(LabPhysical labphy) {
		this.labphy = labphy;
	}

	public LabSugar getLabsugar() {
		return labsugar;
	}

	public void setLabsugar(LabSugar labsugar) {
		this.labsugar = labsugar;
	}

	public LabUrine getLaburine() {
		return laburine;
	}

	public void setLaburine(LabUrine laburine) {
		this.laburine = laburine;
	}

	public LabLipids getLablipids() {
		return lablipids;
	}

	public void setLablipids(LabLipids lablipids) {
		this.lablipids = lablipids;
	}

	public JianyanService getJianyanService() {
		return jianyanService;
	}

	public void setJianyanService(JianyanService jianyanService) {
		this.jianyanService = jianyanService;
	}

	public Integer getFlag() {
		return flag;
	}

	public void setFlag(Integer flag) {
		this.flag = flag;
	}
}
